Create Template
Features Details:
Create WA Template API is used by enterprise to create WA template programmatically. The user will provide WA Template details which includes- Information with respect to Header, Body, Footer, Buttons, Name, Language and Category.
Authorization Mechanism- Token based authentication mechanism will be used for authorizing user to create the WA template. Please refer 'Getting Started - Before You Start' section for more details.
After getting the access token, Enterprises can create template using following API.
Create template:
API Endpoint:
UAT endpoint- https://apiuat.aclwhatsapp.com/access-api/v1/wa/{waba-id}/message_templates
Production endpoint- https://api.aclwhatsapp.com/access-api/v1/wa/{waba-id}/message_templates
Request Type: POST
Sample Curl Request-
curl --location --globoff 'https://apiuat.aclwhatsapp.com/access-api/v1/wa/{waba-id}/message_templates' \
--header 'Authorization: Bearer {token}' \
--header 'Content-Type: application/json' \
--data '{
"name": {templateName},
"category": {category},
"language": {language},
"components": {component},
"allow_category_change": <ALLOW_CATEGORY_CHANGE>
}'
Header Values
Attribute | Description |
---|---|
Authorization | Bearer token - Access token. |
Content-type | Fixed value - application/json. |
Data Object values
Placeholder | Description | Sample Value |
---|---|---|
name(String) | Required(Maximum 512 characters). | order_confirmation |
category(Enum) | Required(Values- Marketing, Utility). | Utility |
allow_category_change(Boolean) | Optional. Set to true to allow Meta to automatically assign a category. If omitted, the template may be rejected due to miscategorization. | true |
language(Enum) | Required. | en_US |
component(Array of Objects) | Required. | See Template Components below |
Template Components:
Templates are composed of various text, media, and interactive components, based on the business needs.
Header Component - Headers are optional components that appear at the top of template messages. Headers support text, media (images, videos, documents), and locations. Templates are limited to one header component.
Text headers-
Syntax-
{
"type": "HEADER",
"format": "TEXT",
"text": "<TEXT>",
"example": {
"header_text": [
"<HEADER_TEXT>"
]
}
}
Placeholder | Description | Sample Value |
---|---|---|
HEADER_TEXT | Sample header text. | Summer Sale |
TEXT | Text to appear in template header when sent. Supports one variable. If the string contains a variable, you must include the example property and a sample variable value. Maximum 60 characters. | Our 1 is on! |
Note :: More details for template creation and payloads can be found at https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates.
Media headers- Media headers can be an image, video, or a document such as a PDF
Payload:-
{
"type": "HEADER",
"format": "<FORMAT>",
"example": {
"header_handle": [
"<HEADER_HANDLE>"
]
}
}
Placeholder | Description | Sample Value |
---|---|---|
FORMAT | Indicates media asset type- IMAGE, VIDEO, or DOCUMENT. | IMAGE |
HEADER_HANDLE | Uploaded media asset handle- Details are mentioned Below. | See Details below |
Sample Media Upload
The sample media file used for template creation will be uploaded using following two step process,
Step-1 Create Media Upload Session
curl --location --globoff --request POST 'https://apiuat.aclwhatsapp.com/access-api/v1/wa/{waba-id}/session/uploads?file_length={file-length}&file_type={file-type}' \
--header 'Authorization: Bearer {token}'
For Production URL is –
Parameter Description-
-
file-length — The file's size, in bytes.
-
file-type — The file's MIME type. Valid values are: application/pdf, image/jpeg, image/jpg, image/png, and video/mp4
-
Bearer-token — The token generated using token API mentioned above
The response of the above step will be session ID
{
"id": "abcd…"
}
Step-2 Initiate Upload
curl --location --globoff 'https://apiuat.aclwhatsapp.com/access-api/v1/wa/{waba-id}/mediaupload/{upload-session-id}' \
--header 'Authorization: Bearer {token}' \
--header 'Content-Type: application/octet-stream' \
--data '{@file-name}
For Production the URL is-
'https://api.aclwhatsapp.com/access-api/v1/wa/{waba-id}/mediaupload/{upload-session-id}
Parameter Description-
-
file-name — File upload Path from the system
-
Bearer-token — Thetoken generated using token API mentioned above
-
upload-session-id — Upload session ID returned in step 1.
The handler generated above will be used in the HEADER_HANDLE attribute of the header component for creating a template
Body Component- Body components are text-only components and are required by all templates. Templates are limited to one body component.
Payload:
{
"type": "BODY",
"text": "<TEXT>",
"example": {
"body_text": [
[
"<BODY_TEXT>"
]
]
}
}
Placeholder | Description | Sample Value |
---|---|---|
BODY_TEXT | Array of sample strings- Number of strings must match the number of variables included in the string. | "Summer Sale", "25OFF" |
TEXT | Text string. Supports multiple variables. If the string contains variables, you must include the example property and sample variable values. Maximun 1024 characters | See Details below |
{
"type": "BODY",
"text": "Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.",
"example": {
"body_text": [
[
"the end of August",
"25OFF",
"25%"
]
]
}
}
Footer Component:- Footers are optional text-only components that appear immediately after the body component. Templates are limited to one footer component.
Syntax:-
{
"type": "FOOTER",
"text": "Use the buttons below to manage your marketing subscriptions"
}
Button Component- Buttons are optional interactive components that perform specific actions when tapped. Templates can have a mixture of up to 10 button components total, although there are limits to individual buttons of the same type as well as combination limits- Currently our platform Support- Phone Number Button, URL Button, Quick Reply Button, Flow Button, Copy Code Button.